<link href="${ctx}/static/assets/bootstrap/js/plugins/zTree/css/metroStyle/metroStyle.css" rel="stylesheet" type="text/css"/>
<script src="${ctx}/static/assets/bootstrap/js/plugins/zTree/js/jquery.ztree.all.min.js" type="text/javascript"></script>
<script src="${ctx}/static/assets/bootstrap/js/plugins/zTree/js/jquery.ztree.exhide.min.js" type="text/javascript"></script>
<script type="text/javascript">
    /**
     * 自定义ztree展开层级
     * @param b true表示obj参数传入的是ztree对象;false表示传入的是树节点对象
     * @param ztreeNodes 子节点
     * @param l 要展开到哪个层级，大于等于0即可
     * @param obj ztree对象或者节点对象（支持ztree对象传入和节点对象传入）
     * @param excludes 排除某些不需要展开的节点的正则表达式
     */
    function ztreeNodesExpand(b,ztreeNodes,l,obj,excludes) {
        if(b){
            const nodes = ztreeNodes.getNodes();
            ztreeNodesExpand(false,nodes,l,ztreeNodes,excludes);
        }else{
            let len=-1;
            if(!isNull(ztreeNodes) && !isNull( (len = ztreeNodes.length) )&&len>0){
                if(l <= ztreeNodes[0].level){
                    return;
                }
                for (let i = 0; i < len; i++) {
                    if(excludes!=null){
                        if(excludes.test(ztreeNodes[i].name)){
                            continue;
                        }
                    }
                    obj.expandNode(ztreeNodes[i], true, false, false, true);
                    const child = ztreeNodes[i].children;
                    ztreeNodesExpand(false,child,l,obj,excludes);
                }
            }
        }
    }
    function isNull(s){
        if(s == null || s == ""){
            return true;
        }
    }

</script>